<template>
  <div class="shop-echarts">
    <div class="shop-up">
      <!-- 昨日销售额 -->
      <div class="shop-little">
        <div class="shop-title">
          <span>昨日销售额</span>
          <span>®</span>
        </div>
        <div class="shop-content">
          <div>560</div>
          <div>
            <span>周同比<i>12%</i></span>
            <span>日同比<i>11%</i></span>
          </div>
        </div>
        <div class="shop-footer">
          <div>日均销售额<i>234</i></div>
        </div>
      </div>
      <!-- 昨日成交订单数 -->
      <div class="shop-little">
        <div class="shop-title">
          <span>昨日成交订单数</span>
          <span>®</span>
        </div>
        <div class="shop-content">
          <div>560</div>
          <div>
            <span>周同比<i>12%</i></span>
            <span>日同比<i>11%</i></span>
          </div>
        </div>
        <div class="shop-footer">
          <div>日均订单<i>234</i></div>
        </div>
      </div>
      <!-- 昨日利润 -->
      <div class="shop-little">
        <div class="shop-title">
          <span>昨日利润</span>
          <span>®</span>
        </div>
        <div class="shop-content">
          <div>560</div>
          <div>
            <span>周同比<i>12%</i></span>
            <span>日同比<i>11%</i></span>
          </div>
        </div>
        <div class="shop-footer">
          <div>日均利润<i>234</i></div>
        </div>
      </div>
    </div>
    <div class="shop-down">
      <!-- 一周利润统计 -->
      <div class="shop-big">
        <div class="shop-title">
          <span>一周利润统计</span>
        </div>
        <div id="shop-echart1"></div>
      </div>
      <!-- 单品销售排行 -->
      <div class="shop-big">
        <div class="shop-title">
          <span>单品销售排行</span>
        </div>
        <div id="shop-echart2"></div>
      </div>
      <!-- 一周销售额统计 -->
      <div class="shop-big">
        <div class="shop-title">
          <span>一周销售额统计</span>
        </div>
        <div id="shop-echart3"></div>
      </div>
    </div>
  </div>
</template>
<script>
import * as echarts from "echarts";

export default {
  mounted() {
    this.drawecharts();
  },
  methods: {
    drawecharts() {
      //获取元素
      var myChart1 = echarts.init(document.getElementById("shop-echart1"));
      var myChart2 = echarts.init(document.getElementById("shop-echart2"));
      var myChart3 = echarts.init(document.getElementById("shop-echart3"));
      //初始化图表并赋值
      //---------------------------折线图------------------------
      myChart1.setOption({
        tooltip: {
          trigger: "axis",
        },
        xAxis: {
          type: "category",
          data: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            data: [150, 230, 224, 218, 135, 147, 260],
            type: "line",
          },
        ],
      });
      //------------------------------柱形图-----------------------------
      myChart2.setOption({
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "shadow",
          },
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        xAxis: {
          type: "value",
          boundaryGap: [0, 0.01],
        },
        yAxis: {
          type: "category",
          data: ["单品6", "单品5", "单品4", "单品3", "单品2", "单品1"],
        },
        series: [
          {
            name: "单品",
            type: "bar",
            data: [18203, 23489, 29034, 104970, 131744, 630230],
          },
        ],
      });
//-------------------------------------折线图----------------
      myChart3.setOption({
        tooltip: {
          trigger: "axis",
        },
        xAxis: {
          type: "category",
          data: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            data: [150, 230, 224, 218, 135, 147, 260],
            type: "line",
          },
        ],
      });
    },
  },
};
</script>
<style lang="less">
.shop-echarts {
  width: 100%;
  height: 620px;
}
.shop-up {
  display: flex;
}
.shop-little {
  flex: 1;
  height: 200px;
  margin: 10px;
  background-color:white;
}
.shop-little:nth-child(2) {
  margin-left: 0;
}
.shop-little:nth-child(3) {
  margin-left: 0;
}
.shop-title {
  height: 50px;
  line-height: 50px;
  margin-left: 20px;
  margin-right: 20px;
}
.shop-title span:nth-child(1) {
  float: left;
  font-size: 16px;
  color: rgb(143, 142, 142);
}
.shop-title span:nth-child(2) {
  float: right;
  font-size: 20px;
  color: rgb(143, 142, 142);
}
.shop-content {
  margin-left: 20px;
  margin-right: 20px;
  height: 100px;
}
.shop-content div:nth-child(1) {
  height: 60px;
  line-height: 60px;
  font-size: 30px;
  font-weight: bolder;
  margin-left: 20px;
}
.shop-content div:nth-child(2) {
  height: 40px;
  line-height: 40px;
  color: rgb(143, 142, 142);
}

.shop-content i {
  font-style: normal;
  margin-left: 20px;
}
.shop-content div:nth-child(2) span:nth-child(2) {
  margin-left: 30px;
}
.shop-footer {
  margin-left: 20px;
  margin-right: 20px;
  height: 50px;
  line-height: 50px;
  color: rgb(143, 142, 142);

  position: relative;
}
.shop-footer::before {
  content: "";
  width: 100%;
  height: 2px;
  position: absolute;
  background-color: rgb(143, 142, 142);
  top: 0;
}
.shop-footer i {
  font-style: normal;
  margin-left: 20px;
}
.shop-down {
  display: flex;
}
.shop-big {
  height: 400px;
  margin-left: 10px;
  background-color: white;
}
.shop-big:nth-child(1) {
  flex: 1;
}
.shop-big:nth-child(2) {
  flex: 1;
}
.shop-big:nth-child(3) {
  flex: 1;
  margin-right: 10px;
}
.shop-big .shop-title {
  position: relative;
}
.shop-big .shop-title::before {
  content: "";
  width: 100%;
  height: 2px;
  background-color: rgb(143, 142, 142);
  position: absolute;
  top: 50px;
}
#shop-echart1{
  width: 100%;
  height: 350px;
}
#shop-echart2{
  width: 100%;
  height: 350px;
}
#shop-echart3{
  width: 100%;
  height: 350px;
}
</style>
